import * as crypto from 'crypto'
import { v4 as uuidv4 } from 'uuid';
import * as svgCaptcha from 'svg-captcha'
export function md5(str: string) {
    return crypto.createHash('md5').update(str).digest('hex')
}

/**
 * 生成唯一id
 * UUID
 * @returns
 */
export function generateUUID(): string {
    const uuid = uuidv4();
    return uuid.replaceAll('-', '');
}
/**
 * 生成时间戳
 * @returns
 */
export function generateTimeStamp(): number {
    return Math.floor(Date.now() / 1000); // 当前时间戳
}

export function generateCaptcha(): svgCaptcha.CaptchaObj {
    return svgCaptcha.create()
}


